package com.tongbo.mobilesafe.ui;

import com.tongbo.mobilesafe.R;
import com.tongbo.mobilesafe.engine.NumberAddressService;

import android.app.Activity;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.EditText;
import android.widget.TextView;

public class QueryNumberActivity extends Activity {
	private EditText et_number;
	private TextView tv_query_number_address;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.query_number);
		tv_query_number_address = (TextView) this.findViewById(R.id.tv_query_number_address);
		et_number = (EditText) this.findViewById(R.id.et_query_number);
	}
	public void query(View view){
		//判断手机号码是否为空
		String phoneNumber = et_number.getText().toString().trim();
		if(TextUtils.isEmpty(phoneNumber)){
			Animation shake = AnimationUtils.loadAnimation(this, R.anim.shake);
			et_number.startAnimation(shake);
		}else{
			//打开数据库查询号码归属地
			String address = NumberAddressService.getAddress(phoneNumber);
			tv_query_number_address.setText("归属地是:"+address);
		}
	}
}
